/**
 */
package org.mro.grib.model.files.secondEdition.products.impl;

import java.nio.ByteBuffer;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.mro.grib.model.files.secondEdition.products.ProductDefinitionTemplate446;
import org.mro.grib.model.files.secondEdition.products.ProductsPackage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Product Definition Template446</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.mro.grib.model.files.secondEdition.products.impl.ProductDefinitionTemplate446Impl#getAerosolType <em>Aerosol Type</em>}</li>
 *   <li>{@link org.mro.grib.model.files.secondEdition.products.impl.ProductDefinitionTemplate446Impl#getTypeOfIntervalForFirstAndSecondSizes <em>Type Of Interval For First And Second Sizes</em>}</li>
 *   <li>{@link org.mro.grib.model.files.secondEdition.products.impl.ProductDefinitionTemplate446Impl#getScaleFactorOfFirstSize <em>Scale Factor Of First Size</em>}</li>
 *   <li>{@link org.mro.grib.model.files.secondEdition.products.impl.ProductDefinitionTemplate446Impl#getScaledValueOfFirstSize <em>Scaled Value Of First Size</em>}</li>
 *   <li>{@link org.mro.grib.model.files.secondEdition.products.impl.ProductDefinitionTemplate446Impl#getScaleFactorOfSecondSize <em>Scale Factor Of Second Size</em>}</li>
 *   <li>{@link org.mro.grib.model.files.secondEdition.products.impl.ProductDefinitionTemplate446Impl#getScaledValueOfSecondSize <em>Scaled Value Of Second Size</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ProductDefinitionTemplate446Impl extends ProductDefinitionTemplate48Impl implements ProductDefinitionTemplate446 {
	/**
	 * The default value of the '{@link #getAerosolType() <em>Aerosol Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getAerosolType()
	 * @generated
	 * @ordered
	 */
	protected static final byte AEROSOL_TYPE_EDEFAULT = 0x00;

	/**
	 * The cached value of the '{@link #getAerosolType() <em>Aerosol Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getAerosolType()
	 * @generated
	 * @ordered
	 */
	protected byte aerosolType = AEROSOL_TYPE_EDEFAULT;

	/**
	 * The default value of the '{@link #getTypeOfIntervalForFirstAndSecondSizes() <em>Type Of Interval For First And Second Sizes</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getTypeOfIntervalForFirstAndSecondSizes()
	 * @generated
	 * @ordered
	 */
	protected static final byte TYPE_OF_INTERVAL_FOR_FIRST_AND_SECOND_SIZES_EDEFAULT = 0x00;

	/**
	 * The cached value of the '{@link #getTypeOfIntervalForFirstAndSecondSizes() <em>Type Of Interval For First And Second Sizes</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getTypeOfIntervalForFirstAndSecondSizes()
	 * @generated
	 * @ordered
	 */
	protected byte typeOfIntervalForFirstAndSecondSizes = TYPE_OF_INTERVAL_FOR_FIRST_AND_SECOND_SIZES_EDEFAULT;

	/**
	 * The default value of the '{@link #getScaleFactorOfFirstSize() <em>Scale Factor Of First Size</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getScaleFactorOfFirstSize()
	 * @generated
	 * @ordered
	 */
	protected static final byte SCALE_FACTOR_OF_FIRST_SIZE_EDEFAULT = 0x00;

	/**
	 * The cached value of the '{@link #getScaleFactorOfFirstSize() <em>Scale Factor Of First Size</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getScaleFactorOfFirstSize()
	 * @generated
	 * @ordered
	 */
	protected byte scaleFactorOfFirstSize = SCALE_FACTOR_OF_FIRST_SIZE_EDEFAULT;

	/**
	 * The default value of the '{@link #getScaledValueOfFirstSize() <em>Scaled Value Of First Size</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getScaledValueOfFirstSize()
	 * @generated
	 * @ordered
	 */
	protected static final int SCALED_VALUE_OF_FIRST_SIZE_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getScaledValueOfFirstSize() <em>Scaled Value Of First Size</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getScaledValueOfFirstSize()
	 * @generated
	 * @ordered
	 */
	protected int scaledValueOfFirstSize = SCALED_VALUE_OF_FIRST_SIZE_EDEFAULT;

	/**
	 * The default value of the '{@link #getScaleFactorOfSecondSize() <em>Scale Factor Of Second Size</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getScaleFactorOfSecondSize()
	 * @generated
	 * @ordered
	 */
	protected static final byte SCALE_FACTOR_OF_SECOND_SIZE_EDEFAULT = 0x00;

	/**
	 * The cached value of the '{@link #getScaleFactorOfSecondSize() <em>Scale Factor Of Second Size</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getScaleFactorOfSecondSize()
	 * @generated
	 * @ordered
	 */
	protected byte scaleFactorOfSecondSize = SCALE_FACTOR_OF_SECOND_SIZE_EDEFAULT;

	/**
	 * The default value of the '{@link #getScaledValueOfSecondSize() <em>Scaled Value Of Second Size</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getScaledValueOfSecondSize()
	 * @generated
	 * @ordered
	 */
	protected static final int SCALED_VALUE_OF_SECOND_SIZE_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getScaledValueOfSecondSize() <em>Scaled Value Of Second Size</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getScaledValueOfSecondSize()
	 * @generated
	 * @ordered
	 */
	protected int scaledValueOfSecondSize = SCALED_VALUE_OF_SECOND_SIZE_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ProductDefinitionTemplate446Impl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return ProductsPackage.Literals.PRODUCT_DEFINITION_TEMPLATE446;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public byte getAerosolType() {
		return aerosolType;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setAerosolType(byte newAerosolType) {
		byte oldAerosolType = aerosolType;
		aerosolType = newAerosolType;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ProductsPackage.PRODUCT_DEFINITION_TEMPLATE446__AEROSOL_TYPE, oldAerosolType, aerosolType));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public byte getTypeOfIntervalForFirstAndSecondSizes() {
		return typeOfIntervalForFirstAndSecondSizes;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setTypeOfIntervalForFirstAndSecondSizes(byte newTypeOfIntervalForFirstAndSecondSizes) {
		byte oldTypeOfIntervalForFirstAndSecondSizes = typeOfIntervalForFirstAndSecondSizes;
		typeOfIntervalForFirstAndSecondSizes = newTypeOfIntervalForFirstAndSecondSizes;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ProductsPackage.PRODUCT_DEFINITION_TEMPLATE446__TYPE_OF_INTERVAL_FOR_FIRST_AND_SECOND_SIZES, oldTypeOfIntervalForFirstAndSecondSizes, typeOfIntervalForFirstAndSecondSizes));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public byte getScaleFactorOfFirstSize() {
		return scaleFactorOfFirstSize;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setScaleFactorOfFirstSize(byte newScaleFactorOfFirstSize) {
		byte oldScaleFactorOfFirstSize = scaleFactorOfFirstSize;
		scaleFactorOfFirstSize = newScaleFactorOfFirstSize;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ProductsPackage.PRODUCT_DEFINITION_TEMPLATE446__SCALE_FACTOR_OF_FIRST_SIZE, oldScaleFactorOfFirstSize, scaleFactorOfFirstSize));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getScaledValueOfFirstSize() {
		return scaledValueOfFirstSize;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setScaledValueOfFirstSize(int newScaledValueOfFirstSize) {
		int oldScaledValueOfFirstSize = scaledValueOfFirstSize;
		scaledValueOfFirstSize = newScaledValueOfFirstSize;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ProductsPackage.PRODUCT_DEFINITION_TEMPLATE446__SCALED_VALUE_OF_FIRST_SIZE, oldScaledValueOfFirstSize, scaledValueOfFirstSize));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public byte getScaleFactorOfSecondSize() {
		return scaleFactorOfSecondSize;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setScaleFactorOfSecondSize(byte newScaleFactorOfSecondSize) {
		byte oldScaleFactorOfSecondSize = scaleFactorOfSecondSize;
		scaleFactorOfSecondSize = newScaleFactorOfSecondSize;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ProductsPackage.PRODUCT_DEFINITION_TEMPLATE446__SCALE_FACTOR_OF_SECOND_SIZE, oldScaleFactorOfSecondSize, scaleFactorOfSecondSize));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getScaledValueOfSecondSize() {
		return scaledValueOfSecondSize;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setScaledValueOfSecondSize(int newScaledValueOfSecondSize) {
		int oldScaledValueOfSecondSize = scaledValueOfSecondSize;
		scaledValueOfSecondSize = newScaledValueOfSecondSize;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ProductsPackage.PRODUCT_DEFINITION_TEMPLATE446__SCALED_VALUE_OF_SECOND_SIZE, oldScaledValueOfSecondSize, scaledValueOfSecondSize));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE446__AEROSOL_TYPE:
				return getAerosolType();
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE446__TYPE_OF_INTERVAL_FOR_FIRST_AND_SECOND_SIZES:
				return getTypeOfIntervalForFirstAndSecondSizes();
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE446__SCALE_FACTOR_OF_FIRST_SIZE:
				return getScaleFactorOfFirstSize();
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE446__SCALED_VALUE_OF_FIRST_SIZE:
				return getScaledValueOfFirstSize();
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE446__SCALE_FACTOR_OF_SECOND_SIZE:
				return getScaleFactorOfSecondSize();
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE446__SCALED_VALUE_OF_SECOND_SIZE:
				return getScaledValueOfSecondSize();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE446__AEROSOL_TYPE:
				setAerosolType((Byte)newValue);
				return;
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE446__TYPE_OF_INTERVAL_FOR_FIRST_AND_SECOND_SIZES:
				setTypeOfIntervalForFirstAndSecondSizes((Byte)newValue);
				return;
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE446__SCALE_FACTOR_OF_FIRST_SIZE:
				setScaleFactorOfFirstSize((Byte)newValue);
				return;
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE446__SCALED_VALUE_OF_FIRST_SIZE:
				setScaledValueOfFirstSize((Integer)newValue);
				return;
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE446__SCALE_FACTOR_OF_SECOND_SIZE:
				setScaleFactorOfSecondSize((Byte)newValue);
				return;
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE446__SCALED_VALUE_OF_SECOND_SIZE:
				setScaledValueOfSecondSize((Integer)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE446__AEROSOL_TYPE:
				setAerosolType(AEROSOL_TYPE_EDEFAULT);
				return;
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE446__TYPE_OF_INTERVAL_FOR_FIRST_AND_SECOND_SIZES:
				setTypeOfIntervalForFirstAndSecondSizes(TYPE_OF_INTERVAL_FOR_FIRST_AND_SECOND_SIZES_EDEFAULT);
				return;
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE446__SCALE_FACTOR_OF_FIRST_SIZE:
				setScaleFactorOfFirstSize(SCALE_FACTOR_OF_FIRST_SIZE_EDEFAULT);
				return;
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE446__SCALED_VALUE_OF_FIRST_SIZE:
				setScaledValueOfFirstSize(SCALED_VALUE_OF_FIRST_SIZE_EDEFAULT);
				return;
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE446__SCALE_FACTOR_OF_SECOND_SIZE:
				setScaleFactorOfSecondSize(SCALE_FACTOR_OF_SECOND_SIZE_EDEFAULT);
				return;
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE446__SCALED_VALUE_OF_SECOND_SIZE:
				setScaledValueOfSecondSize(SCALED_VALUE_OF_SECOND_SIZE_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE446__AEROSOL_TYPE:
				return aerosolType != AEROSOL_TYPE_EDEFAULT;
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE446__TYPE_OF_INTERVAL_FOR_FIRST_AND_SECOND_SIZES:
				return typeOfIntervalForFirstAndSecondSizes != TYPE_OF_INTERVAL_FOR_FIRST_AND_SECOND_SIZES_EDEFAULT;
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE446__SCALE_FACTOR_OF_FIRST_SIZE:
				return scaleFactorOfFirstSize != SCALE_FACTOR_OF_FIRST_SIZE_EDEFAULT;
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE446__SCALED_VALUE_OF_FIRST_SIZE:
				return scaledValueOfFirstSize != SCALED_VALUE_OF_FIRST_SIZE_EDEFAULT;
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE446__SCALE_FACTOR_OF_SECOND_SIZE:
				return scaleFactorOfSecondSize != SCALE_FACTOR_OF_SECOND_SIZE_EDEFAULT;
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE446__SCALED_VALUE_OF_SECOND_SIZE:
				return scaledValueOfSecondSize != SCALED_VALUE_OF_SECOND_SIZE_EDEFAULT;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (aerosolType: "); //$NON-NLS-1$
		result.append(aerosolType);
		result.append(", typeOfIntervalForFirstAndSecondSizes: "); //$NON-NLS-1$
		result.append(typeOfIntervalForFirstAndSecondSizes);
		result.append(", scaleFactorOfFirstSize: "); //$NON-NLS-1$
		result.append(scaleFactorOfFirstSize);
		result.append(", scaledValueOfFirstSize: "); //$NON-NLS-1$
		result.append(scaledValueOfFirstSize);
		result.append(", scaleFactorOfSecondSize: "); //$NON-NLS-1$
		result.append(scaleFactorOfSecondSize);
		result.append(", scaledValueOfSecondSize: "); //$NON-NLS-1$
		result.append(scaledValueOfSecondSize);
		result.append(')');
		return result.toString();
	}

	/* (non-Javadoc)
	 * @see org.mro.grib.model.files.secondEdition.products.impl.ProductDefinitionTemplate48Impl#initialise(java.nio.ByteBuffer)
	 */
	@Override
	public void initialise(ByteBuffer buffer) {
		parameterCategory = buffer.get();
		parameterNumber = buffer.get();
		aerosolType = buffer.get();
		typeOfIntervalForFirstAndSecondSizes = buffer.get();
		scaleFactorOfFirstSize = buffer.get();
		scaledValueOfFirstSize = buffer.getInt();
		scaleFactorOfSecondSize = buffer.get();
		scaledValueOfSecondSize = buffer.getInt();
		typeOfGeneratingProcess = buffer.get();
		backgroundGeneratingProcess = buffer.get();
		analysisOrForecastGeneratingProcess = buffer.get();
		hoursOfObservationalDataCutOff = buffer.getShort();
		minutesOfObservationalDataCutOff = buffer.get();
		indicatorOfUnitOfTimeRange = buffer.get();
		forecastTime = buffer.getInt();
		typeOfFirstFixedSurface = buffer.get();
		scaleFactorOfFirstFixedSurface = buffer.get();
		scaledValueOfFirstFixedSurface = buffer.getInt();
		typeOfSecondFixedSurface = buffer.get();
		scaleFactorOfSecondFixedSurface = buffer.get();
		scaledValueOfSecondFixedSurface = buffer.getInt();
		year = buffer.getShort();
		month = buffer.get();
		day = buffer.get();
		hour = buffer.get();
		minute = buffer.get();
		second = buffer.get();
		numberOfTimeRangeSpecifications = buffer.get();
		totalNumberOfDataValuesMissing = buffer.getInt();
		outermostStatisticalProcess = buffer.get();
		outermostTypeOfTimeIncrement = buffer.get();
		outermostIndicatorOfUnitOfTimeStatisticalProcess = buffer.get();
		outermostLengthOfTheTimeRange = buffer.getInt();
		outermostIndicatorOfUnitOfTimeSuccessiveFields = buffer.get();
		outermostTimeIncrementBetweenSuccessiveFields = buffer.getInt();
		if (numberOfTimeRangeSpecifications > 1) {
			for (int i = 0; i < numberOfTimeRangeSpecifications; i++) {
				additionalStatisticalProcess.add(Byte.valueOf(buffer.get()));
				additionalTypeOfTimeIncrement.add(Byte.valueOf(buffer.get()));
				additionalIndicatorOfUnitOfTimeStatisticalProcess.add(Byte.valueOf(buffer.get()));
				additionalLengthOfTheTimeRange.add(Integer.valueOf(buffer.getInt()));
				additionalIndicatorOfUnitOfTimeSuccessiveFields.add(Byte.valueOf(buffer.get()));
				additionalTimeIncrementBetweenSuccessiveFields.add(Integer.valueOf(buffer.getInt()));
			}
		}
	}
	
} //ProductDefinitionTemplate446Impl
